﻿create database ErpDb;
go
use ErpDb;
go
Create table Department
(
	Id int primary key identity(1,1),
	CreateTime datetime2(7) not null,
	CreateId int not null,
	ModifyId int ,
	ModifyTime datetime2(7),
	IsDelete bit default(0),
	Description varchar(200),
	Name varchar(24) not null
)
Create table Role
(
	Id int primary key identity(1,1),
	CreateTime datetime2(7) not null,
	CreateId int not null,
	ModifyId int ,
	ModifyTime datetime2(7),
	IsDelete bit default(0),
	Description varchar(200),
	Name varchar(24) not null,
	DepartmentId int foreign key references Department(Id)
)

Create table Users
(
	Id int primary key identity(1,1),
	CreateTime datetime2(7) not null,
	CreateId int not null,
	ModifyId int ,
	ModifyTime datetime2(7),
	IsDelete bit default(0),
	Description varchar(200),
	UserName varchar(20) not null Unique ,
	Password varchar(128) not null,
	PrimaryKey varchar(64) not null,
	EMail varchar(32),
	Phone varchar(15),
	IdCard varchar(18),
	RealName varchar(24),
	ImageUrl varchar(256),
	RoleId int foreign key references Role(Id),
	DepartmentId int foreign key references Department(Id)
)
insert into department(name,createtime,createid) values('admin',getdate(),1)
insert into role(name,createtime,createid,departmentid) values('admin',getdate(),1,1)
insert into Users(createtime,createid,departmentid,roleid,username,password,primarykey,realname)
values(getdate(),1,1,1,'admin','C31rudQ4kHIjUCseji3rdg==','56de3f716ea945379a4f7decfffae2a8','admin')



